<HTML><FONT FACE=Arial, Verdana, Sans><TITLE>OrderBook.agent</TITLE><BODY><STYLE TYPE="text/css"><!--.centeralign <BLOCKQUOTE>text-align:center</BLOCKQUOTE>--></STYLE><HEAD><P CLASS="centeralign">OrderBook.agent</P></HEAD><IMG SRC=images/highfrequency.OrderBook.png border=1 alt="Flowchart for OrderBook.agent" title="Flowchart for OrderBook.agent"></P>The package name is "highfrequency".</p>
The following external code is referenced:<BLOCKQUOTE></p>
<li>Components from java.io.*</li></p>
<li>Components from java.math.*</li></p>
<li>Components from java.util.*</li></p>
<li>Components from javax.measure.unit.*</li></p>
<li>Components from org.jscience.mathematics.number.*</li></p>
<li>Components from org.jscience.mathematics.vector.*</li></p>
<li>Components from org.jscience.physics.amount.*</li></p>
<li>Components from repast.simphony.adaptation.neural.*</li></p>
<li>Components from repast.simphony.adaptation.regression.*</li></p>
<li>Components from repast.simphony.context.*</li></p>
<li>Components from repast.simphony.context.space.continuous.*</li></p>
<li>Components from repast.simphony.context.space.gis.*</li></p>
<li>Components from repast.simphony.context.space.graph.*</li></p>
<li>Components from repast.simphony.context.space.grid.*</li></p>
<li>Components from repast.simphony.engine.environment.*</li></p>
<li>Components from repast.simphony.engine.schedule.*</li></p>
<li>Components from repast.simphony.engine.watcher.*</li></p>
<li>Components from repast.simphony.groovy.math.*</li></p>
<li>Components from repast.simphony.integration.*</li></p>
<li>Components from repast.simphony.matlab.link.*</li></p>
<li>Components from repast.simphony.query.*</li></p>
<li>Components from repast.simphony.query.space.continuous.*</li></p>
<li>Components from repast.simphony.query.space.gis.*</li></p>
<li>Components from repast.simphony.query.space.graph.*</li></p>
<li>Components from repast.simphony.query.space.grid.*</li></p>
<li>Components from repast.simphony.query.space.projection.*</li></p>
<li>Components from repast.simphony.parameter.*</li></p>
<li>Components from repast.simphony.random.*</li></p>
<li>Components from repast.simphony.space.continuous.*</li></p>
<li>Components from repast.simphony.space.gis.*</li></p>
<li>Components from repast.simphony.space.graph.*</li></p>
<li>Components from repast.simphony.space.grid.*</li></p>
<li>Components from repast.simphony.space.projection.*</li></p>
<li>Components from repast.simphony.ui.probe.*</li></p>
<li>Components from repast.simphony.util.*</li></p>
<li>Components from simphony.util.messages.*</li></p>
<li>Components from static java.lang.Math.*</li></p>
<li>Components from static repast.simphony.essentials.RepastEssentials.*</li></p>
</BLOCKQUOTE><P></p>
The class "OrderBook" is defined with visibility "public" . This is an agent.</p>
 <BLOCKQUOTE></p>
</p>
    <li>There is a field named "openingPrice" with visibility "public" of type "double" and default value 1095. This is the opening price for today. The block is tagged with the name "Day Opening Price".</li></p>
</p>
    <li>There is a field named "currentPrice" with visibility "public" of type "double" and default value openingPrice. This is the moving, variable price. The block is tagged with the name "Current Price".</li></p>
</p>
    <li>There is a field named "bidBook" with visibility "public" of type "String[]" and default value new String[100]. This is an agent property. The block is tagged with the name "Bid Book".</li></p>
</p>
    <li>There is a field named "askBook" with visibility "public" of type "String[]" and default value new String[100]. This is an agent property. The block is tagged with the name "Ask Book".</li></p>
</p>
    <li>There is a field named "filledOrders" with visibility "public" of type "String[]" and default value new String[10000]. This is an agent property. The block is tagged with the name "Filled Orders".</li></p>
</p>
    </p>
    </p>
        <li>There is a method named "Bid" method has visibility     "public" and parameters [int bidQuantity, String symbol, String agentID]. This is the step behavior. The block is tagged with the name "Receive Bid".</li></p>
    </p>
    </p>
 <BLOCKQUOTE>The code for the "Bid" method is as follows:<BLOCKQUOTE><CODE></p>
</p>
</p>
         Note the simulation time.</p>
        def time = GetTickCountInTimeUnits()</p>
</p>
         This is a task.</p>
        String x = symbol + ", " + agentID + ", " + askQuantity</p>
        int y = bidBook[].length()</p>
        bidBook[y] = x</p>
         End the method.</p>
        return</p>
</p>
    </BLOCKQUOTE></BLOCKQUOTE></CODE></p>
</p>
</p>
    </p>
    </p>
        <li>There is a method named "Ask" method has visibility     "public" and parameters [int askQuantity, String symbol, String agentID]. This is the step behavior. The block is tagged with the name "Receive Ask".</li></p>
    </p>
    </p>
 <BLOCKQUOTE>The code for the "Ask" method is as follows:<BLOCKQUOTE><CODE></p>
</p>
</p>
         Note the simulation time.</p>
        def time = GetTickCountInTimeUnits()</p>
</p>
         This is a task.</p>
        String x = symbol + ", " + agentID + ", " + askQuantity</p>
        int y = askBook[].length()</p>
        askBook[y] = x</p>
         End the method.</p>
        return</p>
</p>
    </BLOCKQUOTE></BLOCKQUOTE></CODE></p>
</p>
</p>
    </p>
    </p>
        <li>There is a method named "clear" method has visibility     "public". Bids and asks are matched and cleared. The block is tagged with the name "Order Clearing Function".</li></p>
    </p>
    </p>
    <BLOCKQUOTE>The clear method is statically scheduled as follows:<BLOCKQUOTE></p>
        <li>start = 1d</li></p>
        <li>interval = 1d</li></p>
        <li>shuffle = true</li></p>
    </BLOCKQUOTE></BLOCKQUOTE></p>
 <BLOCKQUOTE>The code for the "clear" method is as follows:<BLOCKQUOTE><CODE></p>
</p>
</p>
         Note the simulation time.</p>
        def time = GetTickCountInTimeUnits()</p>
</p>
</p>
         This is an agent decision.</p>
        if (askBook.length > bidBook.length) <BLOCKQUOTE></p>
</p>
</p>
             This is a loop.</p>
            for (i in 0..(bidBook.length-1)) <BLOCKQUOTE></p>
</p>
                 This is a task.</p>
                filledOrders[filledOrders.length] = bidBook[i] + ", " + askBook[i] + currentPrice</p>
                 Copy remaining unfilled orders.</p>
                public String[] temp = new String[100]</p>
                setCurrentPrice(currentPrice + 1)</p>
</p>
                 This is a loop.</p>
                for (j in 0..(bidBook.length-askBook.length-1)) <BLOCKQUOTE></p>
</p>
                     This is a task.</p>
                    temp[j] = askBook[bidBook.length+j]</p>
                     This is a task.</p>
                    setAskBook(setAskBook(temp))</p>
                    setBidBook(<BLOCKQUOTE>0</BLOCKQUOTE>)</p>
</p>
                </BLOCKQUOTE></p>
</p>
</p>
            </BLOCKQUOTE></p>
</p>
</p>
        </BLOCKQUOTE> else  <BLOCKQUOTE></p>
</p>
</p>
             This is a loop.</p>
            for (i in 0..(askBook.length-1)) <BLOCKQUOTE></p>
</p>
                 This is a task.</p>
                filledOrders[filledOrders.length] = bidBook[i] + ", " + askBook[i] + currentPrice</p>
                 This is a task.</p>
                public String[] tempArray = new String[100]</p>
                setCurrentPrice(currentPrice + 1)</p>
</p>
                 This is a loop.</p>
                for (k in 0..(askBook.length-bidBook.length-1)) <BLOCKQUOTE></p>
</p>
                     This is a task.</p>
                    tempArray[k] = bidBook[askBook.length+j]</p>
                     This is a task.</p>
                    setBidBook(setBidBook(tempArray))</p>
                    setAskBook(<BLOCKQUOTE>0</BLOCKQUOTE>)</p>
</p>
                </BLOCKQUOTE></p>
</p>
</p>
            </BLOCKQUOTE></p>
</p>
</p>
        </BLOCKQUOTE></p>
         End the method.</p>
        return</p>
</p>
    </BLOCKQUOTE></BLOCKQUOTE></CODE></p>
</p>
</p>
</p>
</BLOCKQUOTE></p>
</p>
</BODY></HTML>